package com.ruoyi.tongban.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.tongban.domain.InsGrade;
import com.ruoyi.tongban.mapper.InsGradeMapper;
import com.ruoyi.tongban.service.IInsGradeService;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 年级Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-03-18
 */
@Service
public class InsGradeServiceImpl implements IInsGradeService 
{
    @Autowired
    private InsGradeMapper insGradeMapper;

    /**
     * 查询年级
     * 
     * @param gradeId 年级ID
     * @return 年级
     */
    @Override
    public InsGrade selectInsGradeById(Long gradeId)
    {
        return insGradeMapper.selectInsGradeById(gradeId);
    }

    @Override
    public List<InsGrade> listInstitutionGrade(Long intitutionId) {
        return insGradeMapper.listInstitutionGrade(intitutionId);
    }

    /**
     * 查询年级列表
     * 
     * @param insGrade 年级
     * @return 年级
     */
    @Override
    public List<InsGrade> selectInsGradeList(InsGrade insGrade)
    {
        return insGradeMapper.selectInsGradeList(insGrade);
    }

    /**
     * 新增年级
     * 
     * @param insGrade 年级
     * @return 结果
     */
    @Override
    public int insertInsGrade(InsGrade insGrade)
    {
        insGrade.setStatus(1);
        insGrade.setCreateUser(SecurityUtils.getLoginUser().getUser().getUserId());
        insGrade.setCreateTime(DateUtils.getNowDate());
        return insGradeMapper.insertInsGrade(insGrade);
    }

    /**
     * 修改年级
     * 
     * @param insGrade 年级
     * @return 结果
     */
    @Override
    public int updateInsGrade(InsGrade insGrade)
    {
        insGrade.setUpdateTime(DateUtils.getNowDate());
        return insGradeMapper.updateInsGrade(insGrade);
    }

    /**
     * 批量删除年级
     * 
     * @param gradeIds 需要删除的年级ID
     * @return 结果
     */
    @Override
    public int deleteInsGradeByIds(Long[] gradeIds)
    {
        return insGradeMapper.deleteInsGradeByIds(gradeIds);
    }

    /**
     * 删除年级信息
     * 
     * @param gradeId 年级ID
     * @return 结果
     */
    @Override
    public int deleteInsGradeById(Long gradeId)
    {
        return insGradeMapper.deleteInsGradeById(gradeId);
    }
}
